import java.util.HashSet;
import java.util.Set;

/**
 * Can be used to tell if an ASCII encoded character
 * is an ASCII encoded decimal digit or an ASCII encoded
 * printable character. 
 * @author Dragon Slayer
 */

public class CharInfo {
	
	public static final int MACNEWLINE = 13;//Mac new Line
	public static final int ASCIIZERO = 48;//ASCII value of zero
	public static final int ASCIININE = 57;//ASCII value of nine
	public static final int ASCIITAB = 9;// ASCII value of tab
	public static final int ASCIIMIN = 32;//Minimum printable ASCII value (other than tab)
	public static final int ASCIIMAX = 126;//Maximum printable ASCII value
	private static Set<Integer> ASCIIDigits;
	private static Set<Integer> ASCIIPrintable;
	
		/**
		 * Initializes an integer set of ASCII digits and an integer set of
		 * ASCII Printable Characters
		 */
		private static void initialize(){
			ASCIIDigits= new HashSet<Integer>();
			ASCIIPrintable = new HashSet<Integer>();
			for (int i = ASCIIZERO; i<=ASCIININE;i++){
				ASCIIDigits.add(i);
			}
			ASCIIPrintable.add(ASCIITAB);
			for(int i = ASCIIMIN; i<=ASCIIMAX;i++){
				ASCIIPrintable.add(i);
			}
		}
		
		
		/**
		 * Checking if the integer passed in is an ASCII encoded decimal digit.
		 * 
		 * @inparam i - integer to be checked.
		 * @return true iff i is an ASCII encoded decimal digit.
		 */
		public static boolean isASCIIDigit(int i){
			if (ASCIIDigits == null){
				initialize();
			}
			return ASCIIDigits.contains(i);
		}
		
		/**
		 * Checks if the integer passid is an ASCII encoded printable 
		 * character
		 * 
		 * @inparam i - integer to be checked.
		 * @return true iff i is an ASCII encoded printable character
		 */
		public static boolean isASCIIPrintable(int i){
			if (ASCIIPrintable == null){
				initialize();
			}
			return ASCIIPrintable.contains(i);
		}
		public static boolean isASCIINonZeroDigit(int i){
			return isASCIIDigit(i) && (i!=ASCIIZERO);
		}
}